package com.zhaojindong.ioc.component.register.conditional;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * created by dean on 2018-08-18
 **/
public class WindowsCondition implements Condition {

    /**
     * @param context  判断条件能使用的上下文
     * @param metadata 注释信息
     * @return 匹配结果
     */
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        Environment environment = context.getEnvironment();
        String property = environment.getProperty("os.name");
        return property.contains("Windows");
    }
}